//
// Created by Administrator on 2016/9/9.
//

#ifndef ZAINTL_FILE_H
#define ZAINTL_FILE_H

#include <dirent.h>
#include <sys/stat.h>

#include <algorithm>
#include <functional>
#include <regex>

#include "FileInputStream.h"
#include "FileOutputStream.h"

namespace ZainTL {
    enum FileStat {
        Is_Nothing,
        Is_File,
        Is_Dir,
        Is_Dir_Invalid
    };

    class File {
    private:
        FileStat mFileStat = Is_Nothing;
        std::string *mAbsolutePath = nullptr;
        std::string *mRelativePath = nullptr;
        std::string *mParentPath = nullptr;
        std::string *mName = nullptr;

        File *mParentFile = nullptr;

        FileOutputStream *mOutputStream = nullptr;
        FileInputStream *mInputStream = nullptr;
    public:
        File(const char *path);

        virtual ~File();

        FileStat getFileStat() const;

        std::string getAbsolutePath() const;

        std::string getRelativePath() const;

        std::string getParentPath() const;

        std::string getName() const;

        void listChildren(std::function<void(ZainTL::File *)> onChildFile);

        char *getFileData(uint64_t &length);

        FileInputStream *getFileInputStream();

        FileOutputStream *getFileOutputStream();
    };
}


#endif //ZAINTL_FILE_H
